import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);

export default new Vuex.Store({
  state:{ //数据管理
    treeParams:{},
    messageDialogObj: {   // alert弹窗
      visible: false,
      time: 0,
      txt: ''
    },
    helpMessage: {
      isShow: false,
      url: '',
      offsetTop: 0,
    }, // 帮助
    loading: false // 加载
  },
  mutations:{ //方法管理
    setTreeUrl(state,treeParams){
      state.treeParams = treeParams;
    },
    setMessageDialogObj(state,payload){
      //console.log(payload);
      state.messageDialogObj = {
        visible: payload.visible,
        time: payload.time,
        txt:  payload.txt
      };
    },
    sethelpMessage ( state,payload ) {
      state.helpMessage = {
        isShow: payload.isShow,
        url: payload.url,
        offsetTop: payload.offsetTop,
      };
    },
    setLoading (state, payload) {
      state.loading = payload
    }
  },
  actions:{
    setTreeUrl(content,treeParams){
      content.commit("setTreeUrl",treeParams);
    },
  },
  getters:{
    getTreeUrl(state){
      return state.treeParams;
    }
  }

});
